const { defineConfig } = require('@vue/cli-service')

const CompressionPlugin = require('compression-webpack-plugin')
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin')

module.exports = defineConfig({
	transpileDependencies: true,
	productionSourceMap: false,
	chainWebpack: config => {
		config.plugins.delete('prefetch')
		config.plugins.delete('preload')
		config.plugin('CompressionPlugin').use(
			new CompressionPlugin({
				test: /\.(js|css|svg|woff|ttf|json|html|scss)$/, // 匹配文件名
				threshold: 10240, // 对超过10k的数据压缩
				deleteOriginalAssets: false // 不删除源文件
			})
		)
		config.plugin('NodePolyfillPlugin').use(new NodePolyfillPlugin())
	}
})
